import { BasicColumn, FormSchema } from '@/components/Table';
import { h } from 'vue';
import {Switch, Tag} from 'ant-design-vue';
import {rewardsSelectListApi} from '@/api/sys/rewards';
import util from '@/utils/util'
import { useMessage } from '@/hooks/web/useMessage';
import Ainput from "@/views/bookManage/components/account/Ainput.vue";

const year=util.times("year");

type CheckedType = boolean | string | number;
export const columns: BasicColumn[] = [
  {
    title: '姓名',
    dataIndex: 'userName',
    width: 180,
  },
  {
    title: '积分',
    dataIndex: 'integral',
    width: 100,
  },
  {
    title: '奖惩类型',
    dataIndex: 'type',
    width: 100,
    customRender: ({ record }) => {
      const type = record.type;
      let text="";
      if(type==1){
        text="奖励";
      }
      if(type==2){
        text="处罚";
      }
      return text;
    },
  },
  {
    title: '奖惩名称',
    dataIndex: 'name',
    width: 120,
  },
  {
    title: '缘由',
    dataIndex: 'note',
  },
  {
    title: '年份',
    dataIndex: 'year',
    width: 100,
  },
  {
    title: '时间',
    dataIndex: 'createTime',
    width: 180,
  },

];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'userName',
    label: '姓名',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    field: 'type',
    label: '奖惩类型',
    component: 'Select',
    componentProps: {
      options: [
        { label: '奖励', value: 1 },
        { label: '处罚', value: 2 },
      ],
    },
    colProps: { span: 6 },
  },
];

export const formSchema: FormSchema[] = [
  {
    label: '姓名',
    field: 'userName',
    component: 'Ainput',
    // rules: [{ required: true }],
    required: true,
    // render: ({ model, field }) => {
    //
    //   return h(Ainput, {
    //     placeholder: '请选择人员',
    //     // value: model[field],
    //     value: model.userName,
    //     mode:"single",// multiple 多选 single 单选
    //     onChange: (e: ChangeEvent) => {
    //       model[field] = e.ids;
    //       model.userName=e.names;
    //     },
    //   });
    // },
  },
  {
    label: '奖惩类型',
    field: 'rewardsId',
    component: 'ApiSelect',
    componentProps: {
      api: rewardsSelectListApi,
      // mode:"multiple",
      resultField:"data",
      labelField: 'name',
      valueField: 'rewardsId',
    },
    required: true,
  },
  {
    field: 'note',
    label: '缘由',
    component: 'Input',
    required: true,

  },
  {
    field: 'year',
    label: '获得年度',
    component: 'Input',
    defaultValue:year,
    required: true,
  },

];
